import request from '@/utils/request'

export const authority = () => {
  return request({
    url: '/roles'
  })
}

export const addRoles = (data) => {
  return request({
    url: '/roles',
    method: 'post',
    data
  })
}

export const delRoles = (id) => {
  return request({
    url: `/roles/${id}`,
    method: 'delete'
  })
}

export const editRoles = (data) => {
  return request({
    url: `/roles/${data.id}`,
    method: 'put',
    data
  })
}

export const treeList = () => {
  return request({
    url: '/rights/tree'
  })
}

export const rightsRolesList = () => {
  return request({
    url: '/rights/list'
  })
}

export const postRolesRights = (id, data) => {
  return request({
    url: `/roles/${id}/rights`,
    method: 'post',
    data
  })
}

export const putRoleRights = (id) => {
  return request({
    url: `/roles/${id}/rights`
  })
}
export const delRoleRights = (oneId, twoId) => {
  return request({
    url: `/roles/${oneId}/rights/${twoId}`,
    method: 'delete'
  })
}
